Current Location: Home> Function Categories> date_add

date_add

DateTime::add alias: Add a certain amount of days, months, years, hours, minutes and seconds to a DateTime object.
Name:date_add
Category:Date and time
Programming Language:php
One-line Description:Add day, month, year, hour, minute, and second to date.

Definition and usage

date_add() function adds a date, month, year, hour, minute, and second to a date.

Example

Added 100 days to October 15, 1980:

 <?php
$date = date_create ( "1980-10-15" ) ;
date_add ( $date , date_interval_create_from_date_string ( "100 days" ) ) ;
echo date_format ( $date , "Ymd" ) ;
?>

Try it yourself

grammar

 date_add ( object , interval ) ;
parameter describe
object Required. Specifies the DateTime object returned by date_create() .
interval Required. Specifies the DateInterval object.
Similar Functions
Popular Articles